From 54336cd68592c0d48749ac5d3ce2c20fbfd2ab46 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Wed, 29 Mar 2006 14:54:43 +0100 Subject: [PATCH] Make maximum number of supported physical CPUs a compile-time option via the 'max_phys_cpus=' compilation parameter. Based on a patch from Aravindh Puthiyaparambil at Unisys. Signed-off-by: Keir Fraser --- xen/Rules.mk | 4 ++++ xen/arch/x86/smpboot.c | 20 ++++++++++++++++---- xen/arch/x86/x86_64/mm.c | 8 +++++--- xen/include/asm-x86/config.h | 8 ++++++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/xen/Rules.mk b/xen/Rules.mk index 55aab4c95e..f887ea44f5 100644 --- a/xen/Rules.mk +++ b/xen/Rules.mk @@ -51,6 +51,10 @@ CFLAGS-$(crash_debug) += -DCRASH_DEBUG CFLAGS-$(perfc) += -DPERF_COUNTERS CFLAGS-$(perfc_arrays) += -DPERF_ARRAYS +ifneq ($(max_phys_cpus),) +CFLAGS-y += -DMAX_PHYS_CPUS=$(max_phys_cpus) +endif + ALL_OBJS := $(ALL_OBJS-y) CFLAGS := $(strip $(CFLAGS) $(CFLAGS-y)) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 5427c42f27..498c2b5ba2 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -880,18 +880,30 @@ static int __devinit do_boot_cpu(int apicid, int cpu) * Returns zero if CPU booted OK, else error code from wakeup_secondary_cpu. */ { - struct vcpu *v; unsigned long boot_error; int timeout; unsigned long start_eip; unsigned short nmi_high = 0, nmi_low = 0; + struct domain *d; + struct vcpu *v; + int vcpu_id; ++cpucount; - v = idle_vcpu[cpu] = alloc_vcpu(idle_vcpu[0]->domain, cpu, cpu); - BUG_ON(v == NULL); + if ((vcpu_id = cpu % MAX_VIRT_CPUS) == 0) { + d = domain_create(IDLE_DOMAIN_ID, cpu); + BUG_ON(d == NULL); + v = d->vcpu[0]; + } else { + d = idle_vcpu[cpu - vcpu_id]->domain; + BUG_ON(d == NULL); + v = alloc_vcpu(d, vcpu_id, cpu); + } + + idle_vcpu[cpu] = v; + BUG_ON(v == NULL); - v->arch.monitor_table = mk_pagetable(__pa(idle_pg_table)); + v->arch.monitor_table = mk_pagetable(__pa(idle_pg_table)); /* start_eip had better be page-aligned! */ start_eip = setup_trampoline(); diff --git a/xen/arch/x86/x86_64/mm.c b/xen/arch/x86/x86_64/mm.c index aa51f434e9..ee8a1a9bf3 100644 --- a/xen/arch/x86/x86_64/mm.c +++ b/xen/arch/x86/x86_64/mm.c @@ -148,12 +148,14 @@ void subarch_init_memory(void) if ( ((offsetof(struct page_info, u.inuse._domain) != (offsetof(struct page_info, count_info) + sizeof(u32)))) || ((offsetof(struct page_info, count_info) & 7) != 0) || - (sizeof(struct page_info) != 40) ) + (sizeof(struct page_info) != + (32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long))) ) { - printk("Weird page_info layout (%ld,%ld,%ld)\n", + printk("Weird page_info layout (%ld,%ld,%ld,%ld)\n", offsetof(struct page_info, count_info), offsetof(struct page_info, u.inuse._domain), - sizeof(struct page_info)); + sizeof(struct page_info), + 32 + BITS_TO_LONGS(NR_CPUS)*sizeof(long)); for ( ; ; ) ; } diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index b901ed3036..3360a2a5a0 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -35,7 +35,15 @@ #define OPT_CONSOLE_STR "com1,vga" +#ifdef MAX_PHYS_CPUS +#define NR_CPUS MAX_PHYS_CPUS +#else #define NR_CPUS 32 +#endif + +#if defined(__i386__) && (NR_CPUS > 32) +#error "Maximum of 32 physical processors supported by Xen on x86_32" +#endif #ifdef CONFIG_X86_SUPERVISOR_MODE_KERNEL # define supervisor_mode_kernel (1) -- 2.30.2